/*

#include <stdio.h>
#include <stdlib.h>

int main()
{
    FILE *fp = fopen("tmp.csv", "a+");
    if (fp == NULL) {
        fprintf(stderr, "fopen() failed.\n");
        exit(EXIT_FAILURE);
    }

    fprintf(fp, "ID,Name,Points\n");
    fprintf(fp, "1,qwe,1.1\n");

    int id = 2;
    char name[5] = "asd";
    float point = 2.2;
    fprintf(fp, "%d,%s,%f\n", id, name, point);

    fclose(fp);
    return 0;
}


*/

/*
// 1-2.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    FILE *fp = fopen("tmp.csv", "r");
    if (fp == NULL) {
        fprintf(stderr, "fopen() failed.\n");
        exit(EXIT_FAILURE);
    }

    char row[80];
    char *token;
    while (fgets(row, 80, fp) != NULL) {
        printf("%s", row);
        token = strtok(row, ","); 
        printf("%s\n", token);
        while (token != NULL) {
            printf("Token: %s\n", token);
            token = strtok(NULL, ",");
        }
    }

    fclose(fp);
    return 0;
}
*/

/*
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
int main (int argc ,char *argv[])
{
    if(argc < 5)
    {
        printf("please input right input");
        //printf("please input the student's information file name");
    }
    else
    {
        // 传入数字     
        int i;
        i = atoi(argv[1]);
        printf("int : %d\n", i);
        
        // 传入字符
        char c;
        c = *argv[2];
        printf("char : %c\n", c);
        
        // 传入字符串
        char* s;
        s = argv[3];
        printf("string : %s\n", s);

        //传入字符串
        char ss[10];
        strcpy (ss,argv[3]);
        printf("string : %s\n", s);

        //传入数组
        int list[10];
        printf("list : ");
        for (int n = 0;n<10; n++ )
        {
            if (argv[4+n] != NULL)
            {
                list[n] = atoi(argv[4 + n]);
                printf("%d ,", list[n]);
            }
            else
                break;
            
        }
    }
    return 0;
}
*/




struct data
{
    int year, month, day;
} a, 
  *p = &a, 
  d[5]={{1998,2,26},{1997,4,9},{2003,8,16}},
  *pd = d;

void main()
{

    printf("year\tmonth\tday\n");
    for (pd=d; pd<d+5; pd++)
    {
        //printf("%d\t%d\t%d\n", ++pd->year, pd->month, pd->day);
        //printf("=================================\n");
        printf("%d\t%d\t%d\n", (++pd)->year, pd->month, pd->day);
        //printf("=====================================\n");
        //printf("%d\t%d\t%d\n", (pd++)->year, pd->month, pd->day);
        
    }

}





#include "stdio.h"
#include "stdlib.h"
#include "string.h"
/*
struct node
{
    char name[20];
    struct node *next;
};

struct node * create()
{
    static struct node *h;
    struct node *p,*q;
    char name[20];
    h = NULL;
    printf("name is : ");
    gets(name);
    while (strlen(name) != 0)
    {
        p = (struct node *)malloc(sizeof(struct node));
        if (p == NULL)
        {
            printf("allocation failure\n");
            exit(0);
        }

        strcpy(p->name,name);
        p->next = NULL;

        if (h==NULL)
            h = p;
        else
            q->next = p;
        q = p;
        printf("name is : ");
        gets(name);

    }
    return h;
}


void main()
{
    struct node *head;
    head = create();
}
*/

void prlist(struct node *head)
{
    struct node *p;
    p = head;
    while(p != NULL)
    {
        printf("%s\n", p->data);
        p = p->next;
    }
}

struct node * delnode(sturct node *head, char *x)
{
    struct node *p,*q;
    static struct node *h;
    if (head == NULL)
    {
        printf("this is an empty list.")
        return head;
    }
    p = head;
    while (strcmp(x,p->data) != 0 && p->next != NULL)
    {
        q = p;
        p = p->next;
    }
    if (strcmp(x,p->name) == 0)
    {
        if (p == head)
            head = p->next;
        else
        {
            p = p->next;
            q->next = p;
        }
    }
    else
        printf("not found.");
    
    h = head;
    return h;
}



struct node *insert (struct node *head, struct node *p0, char *x)
{
    struct node *p,*q;
    static struct node *h;
    if (head == NULL)
    {
        head = p0;
        p0->next = NULL;
    }
    else
    {
        p = head;
        while (strcmp(x,p->data) != 0 && p->next != NULL)
        {
            q = p;
            p = p->next;
        }
        if (strcmp(x,p->data) == 0)
        {
            if (p == head)
            {
                p0->next = p;
                head = p0;
            }
            else
            {
                p0->next = p;
                q->next = p0;
            }
        }
        else
        {
            p->next = p0;
            p0->next = NULL;
        }
    }
    h = head;
    return h;
}










